'''
Created on Dec 24, 2010

@author: Nican
'''

import serial
from time import time

s = serial.Serial(port='COM6', baudrate=57600, timeout=1)
nextTime = 0
count = 0


if __name__ == '__main__':
    while 1:
        
        if s.inWaiting() > 4:
            s.flushInput()
            
            s.write(chr(0))
            s.write(chr(0))
            s.write(chr(0))
            s.write(chr(0))
            s.write(chr(0))
            
            count += 1
            
            if nextTime - time() < 0.0:
                print( count )
                count = 0
                nextTime = time() + 1.0
                
            
            